<?php

class SliderModel {

    private $_db;

    public function __construct() {
		$this->_db = DBFactory::getDbConnection();
    }

    public function get($id) {
        $id = (int) $id;
        $q = $this->_db->prepare("SELECT id, title FROM slider WHERE id=:id");
		$q->execute(array('id'=>$id));
        $data = $q->fetch(PDO::FETCH_ASSOC);
        return new SliderObject($data);
    }

    public function getList() {
        $q = $this->_db->prepare('SELECT id, title FROM slider ORDER BY id DESC');
		$q->execute();
        $tslides = array();
        while ($data = $q->fetch(PDO::FETCH_ASSOC)) {
            $tslides[] = new SliderObject($data);
        }
        return $tslides;
    }

}

?>